package com.cangchu.ui.fragment;

import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import com.cangchu.R;
import com.cangchu.util.HttpUtils;
import com.loopj.android.http.JsonHttpResponseHandler;
import cz.msebera.android.httpclient.Header;
import org.json.JSONException;
import org.json.JSONObject;


public class checkActivityFragment extends BaseFragment<checkActivityFragment> {

    @BindView(R.id.check_id)
    TextView check_id;

    @BindView(R.id.check_people)
    TextView check_people;

    @BindView(R.id.check_stats)
    TextView check_stats;

    @BindView(R.id.check_date)
    TextView check_date;

    @OnClick(R.id.btn_one)
    public void chupan(Button button) {
        Log.d(getLogTag(), "初盘逻辑");

    }

    @OnClick(R.id.btn_two)
    public void fupan(Button button) {
        Log.d(getLogTag(), "复盘逻辑");

    }



    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_check, container, false);
        ButterKnife.bind(this, view);

        HttpUtils.get(getActivity(), "http://121.43.189.138:6000/check", new JsonHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
                if (statusCode == 200) {
                    try {
                        check_id.setText(response.getString("code"));
                        check_people.setText(response.getString("people"));
                        check_stats.setText(response.getString("uuid"));
                        check_date.setText(response.getString("date"));
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            }
        });

        return view;
    }


}
